#pragma once

namespace Tmpl {

class Entity;
class Goal
{
public:
	enum GoalStatus
	{
		GOALSTATUS_NO_SUB_GOALS,
		GOALSTATUS_ACTIVE,
		GOALSTATUS_INACTIVE,
		GOALSTATUS_COMPLETED,
		GOALSTATUS_FAILED
	};

	enum GoalTypes
	{
		GOAL_NONE,
		GOAL_THINK,
		GOAL_MOVE_TO_POS,
		GOAL_FOLLOW_PATH
	};

	Goal(Entity* owner) : mOwner(owner), mStatus(GOALSTATUS_INACTIVE){}
	virtual ~Goal(){}

	Entity* GetOwner() const { return mOwner; }

	virtual void AddSubgoal(Goal* goal){assert("not allowed to add a subgoal to Goal!");}

	virtual char GetType() = 0;

	virtual void Activate() = 0;
	virtual void Process(char threadId) = 0;
	virtual void Terminate() = 0;
	virtual bool HandleMessage(const MsgData& msg){ return false; }
	virtual void Render() const {}

	char GetStatus()const{return mStatus; }
	bool isComplete()const{return mStatus == GOALSTATUS_COMPLETED;} 
	bool isActive()const{return mStatus == GOALSTATUS_ACTIVE;}
	bool isInactive()const{return mStatus == GOALSTATUS_INACTIVE;}
	bool hasFailed()const{return mStatus == GOALSTATUS_FAILED;}

protected:
	Entity* mOwner;
	char mStatus;
};

}